var subMenu = 'main';

function loadSubMenu() {
	subMenu = event.srcElement.id;
	switch(subMenu)
	{
		case "notes":
		case "reviews":
		case "problems":
		case "solutions":
		case "midterms":
		case "exams": document.getElementById('subMenu').src = '[htmls]/select.html?' + subMenu; break;
		default: document.getElementById('subMenu').src = '[htmls]/' + subMenu + '.html'; break;
	}
}

//swaps rollover images
//original image must contain '[0]' before the extension
//rollover image must contain '[1]' before the extension
//the <a> tag must have onMouseOut="swap()" onMouseOver="swap()"
//no id required for the image
function swap() {
	var object = event.srcElement;
	var source = object.src;
	var root = source.substring(0, source.lastIndexOf('['));
	var extension = source.substring(source.lastIndexOf('.'));
	if(source.indexOf('[1]') == -1) //shows rollover image
		object.src = root + '[1]' + extension;
	else if(source.indexOf('[0]') == -1) //shows original image
		object.src = root + '[0]' + extension;
}

//resets the scroll to the top of document
function resetScroll() {
	window.scrollTo(0,0);	
}

//resizes window to width:X and height:Y
function resizeWindow(X,Y) {
	window.resizeTo(X,Y);
}
function centreWindow(X,Y){
	var left = (screen.availWidth - X) / 2;
	var top = (screen.availHeight - Y) / 2;
	window.moveTo(left,top);
}